package com.taritari.journal.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import com.taritari.journal.entity.dto.CommentRoBotDto;
import com.taritari.journal.entity.po.BrowseLog;
import com.taritari.journal.services.BrowseLogService;
import com.taritari.journal.services.CommentService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author taritari
 * @date 2024-04-19 17:32
 * @description 日记队列消费端
 */
@Service
@RabbitListener(queues = {"browsed.TreeHole"}) //队列名
public class BrowsedTreeHoleConsumer {
    @Autowired
    private BrowseLogService browseLogService;
    @RabbitHandler
    public void receiveMessage(String message){
        BrowseLog browseLog = JSONObject.parseObject(message, BrowseLog.class);
        System.out.println("==========================接收消息==========================");
        System.out.println(browseLog);
        browseLog.setBrowseTime(new java.util.Date());
        browseLogService.insertBrowseLog(browseLog);
    }
}
